<!-- 节点 -->
<template>
    <div class="nodeWrap">
        <div class="header">
            <a-space>
                <a-button type="default" class="defaultButton" @click="handOnRefresh">
                    <Icons type="sync"></Icons>
                </a-button>
                <FormProcess :onCallBack="onBackData" :formData="otherData" :dataIndex="dataIndexObj[menuId]">
                </FormProcess>
                <a-space v-if="otherData.processcode">
                    <AddButton :menuId="menuId" :onRefresh="getData" :aParams="otherData">
                    </AddButton>
                </a-space>
            </a-space>
        </div>
        <div class="content">
            <!--  :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }" -->
            <a-table rowKey="id" :columns="columnsList" :data-source="list"
                :scroll="{ y: 'calc(100vh - 162px - 60px)', x: '100%' }" row-key="id" :pagination="false"
                :loading="loading">
                <span slot="options" slot-scope="text, record">
                    <a-space>
                        <AddButton :menuId="menuId" :ids="record.id" :onRefresh="getData">
                        </AddButton>
                        <Edit type="change" :onCallBack="{ onRefresh: getData }" :parendId="otherData.processcode"
                            :record="{ ...record, title: record.showName }" :ids="record.id"></Edit>
                        <DeleteButton :menuId="menuId" :ids="record.id" :onRefresh="getData">
                        </DeleteButton>
                    </a-space>
                </span>
            </a-table>
        </div>
    </div>
</template>
<script>
import { columns, rowKeySet, dataIndexObj } from "./components/js/js.js";
import Icons from "./components/Icons.vue";
import FormProcess from "./components/FormProcess";
import Edit from './components/NodeCom/Edit.vue';
import AddButton from './components/AddButton.vue';
import DeleteButton from './components/DeleteButton.vue';
export default {
    name: 'Node',
    components: {
        Icons,
        FormProcess,
        Edit,
        AddButton,
        DeleteButton,
    },
    props: {
        menuId: {
            type: [String, Number],
        }
    },
    data() {
        return {
            otherData: {},
            loading: false,
            list: [],
            // 复选框选中的值
            selectedRowKeys: [],
            dataIndexObj: dataIndexObj,
        }
    },
    mounted() {
        this.rowKeySet = rowKeySet;
    },
    computed: {
        columnsList() {
            return columns[this.menuId];
        }
    },
    methods: {

        onBackData(val, dataI) {
            let obj = this.otherData;
            obj[dataI] = val;
            this.otherData = JSON.parse(JSON.stringify(obj));
            this.getData(obj);
        },
        handOnRefresh() {
            this.getData();
        },
        getData(aParams) {
            let params = {
                ...this.otherData,
                ...aParams,
            };
            let url;
            if (this.menuId == 91) {
                url = this.$listProcessNode;
                if (!params.processcode) {
                    return;
                }
            }
            if (!url) {
                return;
            }
            this.loading = true;
            this.getAxios(url, params)
                .then((res) => {
                    let data = res.data;
                    this.list = data;
                }).finally(() => {
                    this.loading = false;
                })
        },
        onSelectChange(selectedRowKeys) {
            this.selectedRowKeys = selectedRowKeys;
        }
    }
}
</script>
<style lang="less" scoped>
.nodeWrap {
    background-color: white;
    width: 100%;
    height: 100%;
    padding: 4px 10px;

    .content {
        ::v-deep {
            .ant-table-body {
                overflow: auto !important;
            }
        }

        height: calc(100vh - 116px);
        padding: 10px 0px;
        width: 100%;
    }
}
</style>